﻿using System;
using Company.BLL;
using Company.BLL.GC;
using Company.BLL.Utils;
using Company.BLL.DuLieuChuan;
using Janus.Windows.GridEX;

namespace Company.Interface.GC.PCTFormTemplate
{
    public partial class BoSungNPLFormRegsiter : BaseForm
    {
        public PhuKienDangKy pkdk;
        public string FormName;
        public BoSungNPLFormRegsiter()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void txtMaHS_Leave(object sender, EventArgs e)
        {
            if (!MaHS.Validate(txtMaHS.Text, 10))
            {
                error.SetIconPadding(txtMaHS, -8);
                error.SetError(txtMaHS, "Mã số HS không hợp lệ.");
            }
            else
            {
                error.SetError(txtMaHS, string.Empty);
            }
        }

      

        private void BoSungNPLForm_Load(object sender, EventArgs e)
        {
            pkdk.Load();
            txtGhiChu.Text = pkdk.GhiChu;
            txtVBCP.Text = pkdk.VBCP;
                this.Text = FormName;
            txtMaDV.Text = GlobalSettings.MA_DON_VI;
            txtTen.Text = GlobalSettings.TEN_DON_VI;
            txtSoHopDong.Text = pkdk.SoHopDong;
            txtSoPhuKien.Text = pkdk.SoPhuKien.ToString();
            txtNgayKyHD.Text = pkdk.NgayKy.ToShortDateString();
            ccNgayPhuKien.Text = pkdk.NgayPhuKien.ToShortDateString();
            ctrDonViHaiQuan.Ma = pkdk.MahaiQuan;
            PhuKien pk = new PhuKien();
            pk.MaDoanhNghiep = pkdk.MaDoanhNghiep;
            pk.MahaiQuan = pkdk.MahaiQuan;
            pk.MaPhuKien = pkdk.MaPhuKien;
            pk.NgayKy = pkdk.NgayKy;
            
            pk.SoPhuKien = pkdk.SoPhuKien;
            pk.SoHopDong = pkdk.SoHopDong;
            dgList.DataSource = pk.SelectCollectionBy_SoHopDong_AND_MahaiQuan_AND_MaDoanhNghiep_GC_AND_NgayKy_AND_SoPhuKien_AND_MaPhuKien();
        }

      

        private void dgList_RowDoubleClick(object sender, Janus.Windows.GridEX.RowActionEventArgs e)
        {
           
        }

        private void dgList_LoadingRow(object sender, Janus.Windows.GridEX.RowLoadEventArgs e)
        {
            e.Row.Cells[7].Text = this.DonViTinh_GetName(e.Row.Cells[6].Value);            
        }

        private void dgList_DeletingRecord(object sender, Janus.Windows.GridEX.RowActionCancelEventArgs e)
        {
            
        }

        
    }
}